package com.sdstc.modules.eneity;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.IdCardNumberMethod;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author ：wk
 * @date ：Created in 2022/10/23 13:16
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("person")
public class PersonEntity extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private String id;

    // 所属部门
    private String orgId;

    // 姓名
    private String name;

    // 警号
    private String policeNo;

    // 身份证号
    private String identityNo;

    // 警衔
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String jobTitle;

    // 职级层次 大类
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String jobLevel;

    // 职级层次 小类
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String jobLevelSmall;

    // 联系方式
    private String contactPhone;

    // 状态
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String status;

    // 领导类型
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String leaderType;

    // 职务大类   用枚举
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String  postBigCateCode;

    // 职务小类   小类用字典
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String  postSmallCateCode;

    @TableField(exist = false)
    private String postSmallCateCodeLabel;

    @TableField(exist = false)
    private String jobLevelSmallLabel;

    @TableField(exist = false)
    private String orgName;

    // 性别
    private String sex;

    // 学历
    private String education;

    // 职务名称
    private String positionTitle;

    @TableField(exist = false)
    private Integer startAge;

    @TableField(exist = false)
    private Integer endAge;

    public String getAgeRange() {
        String ageForIdCard = IdCardNumberMethod.getAgeForIdCard(identityNo);
        int age;
        if (StringUtils.isNotBlank(ageForIdCard) && (age = Integer.parseInt(ageForIdCard)) > 0) {
            if (age <= 25) {
                return "25岁及以下";
            }else if (age <= 30) {
                return "26-30";
            }else if (age <= 35) {
                return "31-35";
            }else if (age <= 40) {
                return "36-40";
            }else if (age <= 45) {
                return "41-45";
            }else if (age <= 50) {
                return "46-50";
            }else if (age <= 55) {
                return "51-55";
            }else {
                return "56岁以上";
            }
        }
        return "-1";
    }


}
